package com.bodu.exchange.controller;

import com.bodu.core.entity.result.Result;
import com.bodu.exchange.client.ExchangeBookClient;
import com.bodu.exchange.entity.request.ExchangeBookRequest;
import com.bodu.exchange.entity.request.UserExchangeBookRequest;
import com.bodu.exchange.entity.vo.ExchangeBookVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 */
@Api(value = "账本API", tags = "登录页面API")
@RestController
@RequestMapping("api/exchange-book")
public class ExchangeBookApiController {

    @Autowired
    private ExchangeBookClient exchangeBookClient;

    @ApiModelProperty("创建账本")
    @PostMapping("createExchangeBook")
    public Result<Long> createExchangeBook(@RequestBody ExchangeBookRequest request) {
        return exchangeBookClient.createExchangeBook(request);
    }

    @ApiModelProperty("修改账本")
    @PostMapping("updateExchangeBook")
    public Result<Long> updateExchangeBook(@RequestBody ExchangeBookRequest request) {
        return exchangeBookClient.updateExchangeBook(request);
    }

    @PostMapping("bookList")
    @ApiModelProperty("查询账本")
    public Result<ExchangeBookVo> bookList(@RequestBody UserExchangeBookRequest request) {
        return exchangeBookClient.bookList(request);
    }

    @ApiModelProperty("修改账本状态")
    @PostMapping("updateDefaultExchangeBookStatus")
    public Result<Integer> updateDefaultExchangeBookStatus(@RequestBody ExchangeBookRequest request) {
        return exchangeBookClient.updateDefaultExchangeBookStatus(request);
    }
}
